/*
 * @Descripttion: 
 * @Author: Haixu He
 * @Date: 2021-12-27 19:24:24
 */
var geometry = ee.FeatureCollection("users/joeyqmf83/Shenzhen_NEW");
Map.addLayer(geometry,{},"Shenzhen")

var imageCollection = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2").filter(ee.Filter.eq('WRS_ROW',44)).filterBounds(geometry)

var year = 2021

var month_1 = 11
var day_1 = 7

var month_2 = 11
var day_2 = 8

var start_1 = year.toString()+'-'+month_1.toString()+'-'+(day_1-1).toString()
var end_1 = year.toString()+'-'+month_1.toString()+'-'+(day_1+1).toString()

var start_2 = year.toString()+'-'+month_2.toString()+'-'+(day_2-1).toString()
var end_2 = year.toString()+'-'+month_2.toString()+'-'+(day_2+1).toString()


// var imageCollection_1 = imageCollection.filter(ee.Filter.eq('WRS_PATH',122)).filterDate(start_1,end_1)
// var imageCollection_2 = imageCollection.filter(ee.Filter.eq('WRS_PATH',121)).filterDate(start_2,end_2)

var imageCollection_1 = imageCollection.filter(ee.Filter.eq('WRS_PATH',122)).sort( 'CLOUD_COVER').filter(ee.Filter.calendarRange(year,year,'year'))  // 按照云量排序
var imageCollection_2 = imageCollection.filter(ee.Filter.eq('WRS_PATH',121)).sort( 'CLOUD_COVER').filter(ee.Filter.calendarRange(year,year,'year'))

print(imageCollection_1)
print(imageCollection_2)
var first_image = imageCollection_1.first().clip(geometry);
var second_image = imageCollection_2.first().clip(geometry);

Map.addLayer(first_image,{},"first_image")
Map.addLayer(second_image,{},"second_image")

print(first_image)
print(second_image)

Export.image.toDrive({
    image: first_image.float(),
    description: year.toString()+'_44_122',
    folder: 'ShenZhen',
    scale: 30,
    region: geometry,
    fileDimensions: 1280,
});

Export.image.toDrive({
    image: second_image.float(),
    description: year.toString()+'_44_121',
    folder: 'ShenZhen',
    scale: 30,
    region: geometry,
    fileDimensions: 1280,
});

